<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META name="generator" content="HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org">
<TITLE>Conditional blocks</TITLE>
<META name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
<LINK rel="HOME" title="Abyss Web Server For Windows User's Guide" href="index.html">
<LINK rel="UP" title="eXtended Server Side Includes" href="ssi.html">
<LINK rel="PREVIOUS" title="Directives" href="directives.html">
<LINK rel="NEXT" title="Encoding" href="ssiencoding.html">
<LINK rel="STYLESHEET" type="text/css" href="stylesheet.css">
<META name="AppleIcon" content="icon.png">
<META name="AppleTitle" content="Conditional blocks">
<META name="Description" content="Conditional blocks">
<META name="AppleOrder" content="">
</HEAD>
<BODY class="SECT1" bgcolor="#FFFFFF" text="#000000">
<DIV class="NAVHEADER">
<TABLE summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<TR>
<TH colspan="3" align="center">Abyss Web Server For Windows User's Guide</TH>
</TR>
<TR>
<TD width="10%" align="left" valign="bottom"><A href="directives.html" accesskey="P">Prev</A></TD>
<TD width="80%" align="center" valign="bottom">Chapter 7. eXtended Server Side Includes</TD>
<TD width="10%" align="right" valign="bottom"><A href="ssiencoding.html" accesskey="N">Next</A></TD>
</TR>
</TABLE>
<HR align="left" width="100%"></DIV>
<DIV class="SECT1">
<H1 class="SECT1"><A name="SSICONDITIONAL" id="SSICONDITIONAL">Conditional blocks</A></H1>
<DIV class="SECT2">
<H2 class="SECT2"><A name="AEN2401" id="AEN2401">Syntax</A></H2>
<P>Conditional blocks in XSSI look as follows:</P>
<PRE class="PROGRAMLISTING">
   &lt;!-- #if expr="test_expr_1" --&gt;
           Content to process if test_expr_1 is true
   &lt;!-- #elif expr="test_expr_2" --&gt;
           Content to process if test_expr_2 is true
           .
           .
   &lt;!-- #elif expr="test_expr_n" --&gt;
                Content to process if test_expr_n is true
   &lt;!-- #else --&gt;
                Content to process if all the above tests are false
   &lt;!-- #endif --&gt;
</PRE>
<KBD class="USERINPUT">#elif</KBD> sections are optional. A conditional block can have zero or many of them. The <KBD class="USERINPUT">#else</KBD> is optional and a conditional block can have either no <KBD class="USERINPUT">#else</KBD> or exactly one.
<P>Conditional blocks can be nested.</P>
</DIV>
<DIV class="SECT2">
<H2 class="SECT2"><A name="AEN2409" id="AEN2409">Expression evaluation</A></H2>
<P>The value of the <KBD class="USERINPUT">expr</KBD> attribute inside <KBD class="USERINPUT">#if</KBD> and <KBD class="USERINPUT">#elif</KBD> directives is considered as an expression which evaluates to true or false according to these rules:</P>
<DIV class="VARIABLELIST">
<DL>
<DT><SPAN class="emphasis"><I class="EMPHASIS">string</I></SPAN></DT>
<DD>
<P>Evaluates to true if <SPAN class="emphasis"><I class="EMPHASIS">string</I></SPAN> is not empty.</P>
</DD>
<DT><SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">&lt;</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>, <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">&lt;=</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>, <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">&gt;</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>, <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">&gt;=</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>, <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">==</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN></DT>
<DD>
<P>Performs a lexicographic comparison between <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> and <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>.</P>
</DD>
<DT><SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">=</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>, <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> <KBD class="USERINPUT">!=</KBD> <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN></DT>
<DD>
<P>Performs a lexicographic comparison between <SPAN class="emphasis"><I class="EMPHASIS">string_1</I></SPAN> and <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN>. If <SPAN class="emphasis"><I class="EMPHASIS">string_2</I></SPAN> has the form <KBD class="USERINPUT">/</KBD><SPAN class="emphasis"><I class="EMPHASIS">regex</I></SPAN><KBD class="USERINPUT">/</KBD>, a regular expression matching operation will take place instead. Matched sub-strings are captured inside the variables <KBD class="USERINPUT">$0</KBD>, <KBD class="USERINPUT">$1</KBD>, ..., <KBD class="USERINPUT">$9</KBD>. For more information about backreferences, refer to the "<A href="regex.html">Regular Expressions</A>" appendix.</P>
</DD>
<DT><SPAN class="emphasis"><I class="EMPHASIS">test_expr_1</I></SPAN> <KBD class="USERINPUT">&amp;&amp;</KBD> <SPAN class="emphasis"><I class="EMPHASIS">test_expr_2</I></SPAN></DT>
<DD>
<P>Evaluates to true if both <SPAN class="emphasis"><I class="EMPHASIS">test_expr_1</I></SPAN> and <SPAN class="emphasis"><I class="EMPHASIS">test_expr_2</I></SPAN> expressions are true.</P>
</DD>
<DT><SPAN class="emphasis"><I class="EMPHASIS">test_expr_1</I></SPAN> <KBD class="USERINPUT">||</KBD> <SPAN class="emphasis"><I class="EMPHASIS">test_expr_2</I></SPAN></DT>
<DD>
<P>Evaluates to true if at least one of the expressions <SPAN class="emphasis"><I class="EMPHASIS">test_expr_1</I></SPAN> and <SPAN class="emphasis"><I class="EMPHASIS">test_expr_2</I></SPAN> is true.</P>
</DD>
<DT><KBD class="USERINPUT">!</KBD> <SPAN class="emphasis"><I class="EMPHASIS">test_expr</I></SPAN></DT>
<DD>
<P>Evaluates to true if <SPAN class="emphasis"><I class="EMPHASIS">test_expr</I></SPAN> is false.</P>
</DD>
<DT><KBD class="USERINPUT">(</KBD> <SPAN class="emphasis"><I class="EMPHASIS">test_expr</I></SPAN> <KBD class="USERINPUT">)</KBD></DT>
<DD>
<P>Evaluates to true if <SPAN class="emphasis"><I class="EMPHASIS">test_expr</I></SPAN> is true. Parentheses are used to enclose sub-expressions and supersede the priorities of their operators.</P>
</DD>
</DL>
</DIV>
<P><KBD class="USERINPUT">!</KBD> has higher priority than <KBD class="USERINPUT">&amp;&amp;</KBD> and <KBD class="USERINPUT">||</KBD> which at their turn have higher priority than <KBD class="USERINPUT">=</KBD>, <KBD class="USERINPUT">!=</KBD>, <KBD class="USERINPUT">==</KBD>, <KBD class="USERINPUT">&lt;=</KBD>, <KBD class="USERINPUT">&gt;=</KBD>, <KBD class="USERINPUT">&lt;</KBD>, and <KBD class="USERINPUT">&gt;</KBD>.</P>
</DIV>
</DIV>
<DIV class="NAVFOOTER">
<HR align="left" width="100%">
<TABLE summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<TR>
<TD width="33%" align="left" valign="top"><A href="directives.html" accesskey="P">Prev</A></TD>
<TD width="34%" align="center" valign="top"><A href="index.html" accesskey="H">Home</A></TD>
<TD width="33%" align="right" valign="top"><A href="ssiencoding.html" accesskey="N">Next</A></TD>
</TR>
<TR>
<TD width="33%" align="left" valign="top">Directives</TD>
<TD width="34%" align="center" valign="top"><A href="ssi.html" accesskey="U">Up</A></TD>
<TD width="33%" align="right" valign="top">Encoding</TD>
</TR>
</TABLE>
</DIV>
<DIV class="COPYRIGHT">Copyright &copy; 2001-2009 Aprelium</DIV>
</BODY>
</HTML>
